<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <style>

    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">添加日程</div>
      </div>
      <!--  -->
      <div class="x-pro-list">
        <div class="x-pro-row">
          <div class="x-pro-label">标题:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="title"></el-input>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">开始时间:</div>
          <div class="x-pro-input">
            <el-date-picker v-model="starttime" type="date" placeholder="选择开始日期"  format="yyyy 年 MM 月 dd 日" value-format="yyyyMMdd" :editable="notkey"></el-date-picker>
          </div>
        </div>
        <div class="x-pro-row">
          <div class="x-pro-label">结束时间:</div>
          <div class="x-pro-input">
            <el-date-picker v-model="endtime" type="date" placeholder="选择结束日期"  format="yyyy 年 MM 月 dd 日" value-format="yyyyMMdd" :editable="notkey"></el-date-picker>
          </div>
        </div>
        <div class="x-pro-row x-pro-rowblock">
          <div class="x-pro-label">完成结果:</div>
          <div class="x-pro-input">
            <el-input placeholder="请输入内容" v-model="finishpro" type="textarea" :rows="4"></el-input>
          </div>
        </div>
      </div>
      <!--  -->
      <el-button type="success" style="width: 90%;margin: auto;display: block;" @click="isok" :disabled="disabled">提交</el-button>
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));

    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          title:'',
          starttime:'',
          endtime:'',
          finishpro:'',
          notkey:false,
          disabled:false
        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;

      },
      methods: {
        //
        isok:function(){
          var that = this;
          that.disabled = true;
          console.log(that.disabled);
          api.ajax({
            url:baseurl+'api/instruct/addTodayview',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                title:that.title,
                start_time:that.starttime,
                end_time:that.endtime,
                result_str:that.finishpro

              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                api.alert({
                    title: '提交成功',
                    msg: '',
                }, function(ret, err) {
                    api.closeWin()
                });

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
              setTimeout(() => {
                that.disabled = false;
              }, 2000)
            }else{
                setTimeout(() => {
                    that.disabled = false;
                }, 2000)
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },

      }
    })
	}


	</script>
</body>
</html>
